package com.aestheticshare.main;

import android.app.SearchManager;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.provider.BaseColumns;

public class FriendsSuggestionProvider extends ContentProvider   {
	
    public static final String FRIEND_MIME_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/com.aestheticshare.friend";
	
    private static final int SEARCH_SUGGEST = 1;
    private static final UriMatcher uriMatcher =  new UriMatcher(UriMatcher.NO_MATCH);
    
	@Override
	public boolean onCreate() {
		uriMatcher.addURI(getContext().getResources().getString(R.string.provider_authority), "friends", SEARCH_SUGGEST);
		return true;
	}

	@Override
	public String getType(Uri uri) {
		Utils.log();
		switch (uriMatcher.match(uri)) {
        case SEARCH_SUGGEST:
            return FRIEND_MIME_TYPE;
		}
		throw new IllegalArgumentException("Unknown URI:" + uri);
	}

	@Override
	public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
		Utils.log();
		switch (uriMatcher.match(uri)) {
        case SEARCH_SUGGEST:{
        	String[] columns = {
        			BaseColumns._ID, 
        			SearchManager.SUGGEST_COLUMN_TEXT_1, 
        			SearchManager.SUGGEST_COLUMN_INTENT_DATA
        	};
        	MatrixCursor cursor = new MatrixCursor(columns);
        	cursor.addRow(new String[]{"0", "Jack", ""});
        	cursor.addRow(new String[]{"1", "Rose", ""});
        	return cursor;
        }
        default:
            throw new IllegalArgumentException("Unknown URI: " + uri);		
		}
	}

	@Override
	public Uri insert(Uri arg0, ContentValues arg1) {
        throw new UnsupportedOperationException();
	}
	@Override
	public int delete(Uri arg0, String arg1, String[] arg2) {
        throw new UnsupportedOperationException();
	}
	@Override
	public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
        throw new UnsupportedOperationException();
	}
}
